﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace AnimationManagerWindow
{
    /// <summary>
    /// TowThumbSilder.xaml 的交互逻辑
    /// </summary>
    public partial class TowThumbSilder : UserControl
    {
        public TowThumbSilder()
        {
            InitializeComponent();
        }

        private void Thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
        {
            //e.HorizontalChange;
           
        }

        private void ThumbLeft_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
        {
            var leftLoc = Canvas.GetLeft(leftThumb);
            var rightLoc = Canvas.GetLeft(rightThumb);
            righttb.Text = rightLoc.ToString();
            lefttb.Text = leftLoc.ToString();
            Canvas.SetLeft(leftThumb, Canvas.GetLeft(leftThumb) + e.HorizontalChange);
            if (leftLoc<rightLoc)
            {
                Canvas.SetLeft(middleRect, leftLoc);
            }
            
            middleRect.Width = (rightLoc<leftLoc)?0:rightLoc - leftLoc;
        }

        private void ThumbRight_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
        {
            var leftLoc = Canvas.GetLeft(leftThumb);
            var rightLoc = Canvas.GetLeft(rightThumb);
            righttb.Text = rightLoc.ToString();
            lefttb.Text = leftLoc.ToString();
            if (rightLoc>=leftLoc)
            {
                Canvas.SetLeft(rightThumb, Canvas.GetLeft(rightThumb) + e.HorizontalChange);

            }
            else
            {
                Canvas.SetLeft(rightThumb, leftLoc);
                rightLoc = leftLoc;
            }
            Canvas.SetLeft(middleRect, leftLoc);
            middleRect.Width = (rightLoc < leftLoc) ? 0 : rightLoc - leftLoc;
        }
    }
}
